//
//  PoolingModel.h
//  tEngineTechDemo
//
//  Created by Gareth Williams on 16/01/2012.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
//  naive pooling model, primarily used to reduce the load of 
//  instantiation for view components
//  this pooling model takes a poolable factory which it uses to create new instances of whatever needs pooling
//

#import <Foundation/Foundation.h>

@protocol Poolable <NSObject> //because we expect a clean method

-(void)clean;

@end

//create poolable objects
@protocol PoolableFactory <NSObject>

+(id<Poolable>)create;

@end

@interface PoolingModel : NSObject

@property(readonly, nonatomic) NSMutableArray* pool;
@property(readonly, nonatomic) int maxPoolSize; //in practice this currently isn't used.

-(id)initWithFactory:(Class<PoolableFactory>)factoryToUse PoolSize:(int)size withMaxSize:(int)maxSize;

-(void)checkIn:(id<Poolable>)object;
-(id<Poolable>)checkOut;

@end
